﻿'ADAM CORTEZ
Imports DARSClassLibrary
Imports DBUtilitiesLibrary

Public Class ChangeStudentMajor
    Inherits System.Web.UI.Page
    'poop
    Dim ws As New DO_NOT_MOVE_ME_FROM_THIS_PROJECT.DARSWebservice
    Dim studID As String
    Dim majorDS As DataSet
    Dim studentDS As DataSet

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Check if user is logged in
        If Session("CurrentUser") Is Nothing Then
            Response.Redirect("NotLoggedIn.aspx")
            Exit Sub
        End If

        'Loads the Student object from session and displays his/her name
        Dim objStudent As Student
        objStudent = CType(Session("CurrentUser"), Student)
        Dim stdID As String = objStudent.studentID
        Session("StudentID") = stdID

        If Not IsPostBack Then
            majorDS = ws.getAllMajors()
            ddlMajors.DataSource = majorDS
            ddlMajors.DataTextField = "MajorID"
            ddlMajors.DataValueField = "MajorID"
            ddlMajors.DataBind()
            pnlConfirm.Visible = False
            pnlNewInfo.Visible = False
        End If

    End Sub

    Protected Sub Submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
        'studentDS = ws.getStudentMajors(txtStudentID.Text)
        'gvStudentInfo.DataSource = studentDS
        'gvStudentInfo.DataBind()

        'majorDS = ws.getAllMajors()
        'gvMajors.DataSource = majorDS
        'gvMajors.DataBind()
        'Dim majorPathDS As New DataSet
        'majorPathDS = ws.getMajorDegreePaths(ddlMajors.Text, ddlDegree.Text)
        'ddlPaths.DataSource = majorDS
        'ddlPaths.DataTextField = "MajorTitle"
        'ddlPaths.DataValueField = "MajorTitle"
        'ddlPaths.DataBind()
        pnlConfirm.Visible = False
        lblConfirmMajor.Text = ddlMajors.Text
        lblConfirmDegree.Text = ddlDegree.Text
        pnlConfirm.Visible = True
    End Sub



    Protected Sub btnConfirm_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConfirm.Click
        Dim strSQL As String = "INSERT Into StudentMajorUpdateRequest (StudentID, RequestDate, MajorID, DegreeID, PathID) Values " & _
            "('" & CStr(Session("StudentID")) & "', '" & DateTime.Now.ToString & "', '" & lblConfirmMajor.Text & "', '" & lblConfirmDegree.Text & "', 1)"
        Dim objDB As New DARSDBConnection
        Dim x As Integer = objDB.doUpdate(strSQL)
        If x = 1 Then
            lblMessage.Text = "Major Request sent successfully!"
        Else
            lblMessage.Text = "Major Request failed..."
        End If
        pnlNewInfo.Visible = True
    End Sub

    Protected Sub logout(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogout.ServerClick
        Session.Abandon()
        Response.Redirect("NotLoggedIn.aspx")
    End Sub

    Protected Sub home(ByVal sender As Object, ByVal e As EventArgs) Handles btnhome.ServerClick
        Response.Redirect("LandingPage.aspx")
    End Sub



End Class